import request from "@/utils/request";
const OPPORTUNITY_BASE_URL = "/api/v1/opportunityPayment";
/**
 * 客户管理 - 设计师
 */
const opportunityPaymentAPI = {
  getOpportunityAndRecord(data: any) {
    return request({
      url: `/api/v1/requirementPayment/opportunityAndRecord/page`,
      method: "post",
      data,
    });
  },
  getRequirementPayment(data: any) {
    return request({
      url: `/api/v1/requirementPayment/page`,
      method: "post",
      data,
    });
  },
  getDetail(data: any) {
    return request({
      url: `/api/v1/requirementPayment/getDetail`,
      method: "post",
      data,
    });
  },
  // 成交历史修改数据
  getConDynamic(data: any) {
    return request({
      url: `/api/v1/conDynamic/page`,
      method: "post",
      data,
    });
  },
  // 成交历史数据
  getHistory(data: any) {
    return request({
      url: `/api/v1/transactionRecords/getHistory`,
      method: "post",
      data,
    });
  },
  /**
   * 客户管理 - 装修公司
   */
  getDecorationPayment(data: { pageNum: number; pageSize: number }) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/material/page`,
      method: "post",
      data,
    });
  },
  // 成交历史
  getRelationshipMapDetail(data: {
    pageNum: number;
    pageSize: number;
    opportunityId: number;
    opportunitySource: number;
  }) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/relationshipMap/detail`,
      method: "post",
      data,
    });
  },
  /**
   * 设置聊天用户
   */
  setChatUser(data: ImUserAllotQuery) {
    return request<any, any>({
      url: `/api/v1/requirementPayment/setChatUser`,
      method: "post",
      data,
    });
  },
  /**
   * @params houseId
   * @params chatUserId
   * 已经存在客户关系的公司列表
   */
  getCompanyList(data: { chatUserId: number; opportunityId: number; opportunityType: number }) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/company/list`,
      method: "get",
      params: data,
    });
  },
  /**
   * 项目经理已经存在客户关系的公司列表
   */

  getMerchantList(data: any) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/company/listByMerchantUserId`,
      method: "get",
      params: data,
    });
  },
  /**
   * 获取可分配沟通人列表
   * @param data
   */
  getAllotChatUsers(data: ImUserAllotQuery) {
    return request<any, any>({
      url: `/api/v1/opportunity/getAllotChatUsers`,
      method: "post",
      data,
    });
  },
  /**
   * 去聊天
   * @param data
   */
  toChat(data: ImUserAllotQuery) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/toChat`,
      method: "post",
      data,
    });
  },
  /**
   * 去群聊
   * @param data
   */
  toTeamChat(data: ImUserAllotQuery) {
    return request<any, any>({
      url: `${OPPORTUNITY_BASE_URL}/toTeamChat`,
      method: "post",
      data,
    });
  },
  // 成交历史数据
  getHistoryWithConsumer(data: any) {
    return request({
      url: `/api/v1/transactionRecords/getHistoryWithConsumer`,
      method: "post",
      data,
    });
  },
};

export default opportunityPaymentAPI;

/**
 * 聊天分配对接人查询参数
 */
export interface ImUserAllotQuery {
  /** 主键 ID */
  id?: number;

  /** 机会 ID */
  opportunityId?: number;

  /** 付费人公司 ID */
  payCompanyId?: number;

  /** 付费人 ID */
  payUserId?: number;

  /** 机会来源（1-设计机会，2-建材机会） */
  opportunitySource?: number;

  /** 设置聊天用户 ID */
  chatUserId?: number;
}
